<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>函数定义的三种方法</title>
</head>
<body>
	<script type="text/javascript">
		// function语句
		function test1(){
			alert("test1");
		}
		// test1();
		
		// Function构造函数
		var test2 = new Function("a","b","alert(a+b);");
		// test2(2,18);

		// 函数直接量
		var test3 = function(){alert("test3");}
		// test3();

		//比较效率
		var data = new Date();
		var time = data.getTime();
		for(var i=0;i<100000;i++){
			// function fun1(){;}  // 1-3ms
			//var fun3 = function(){;} // 6-11 ms
			// var fun2 = new Function(); // 90-160ms
		}
		var data1 = new Date();
		var time1 = data1.getTime();
		alert(time1-time);
		
	</script>
</body>
</html>